package org.jproxy.sample;

import javax.servlet.http.HttpServletRequest;

import org.jproxy.ResourcePool;
import org.jproxy.annotations.Service;

@Service(bindName="TestFacade")
public class TestFacade
{
	public String test()
	{
		HttpServletRequest request = ResourcePool.getInstance().getHttpServletRequest();
		if(request.getSession().getAttribute("rod") == null)
		{
			System.out.println("setando valor...");
			request.getSession().setAttribute("rod", "lalala");
		}
		System.out.println("Teste");
		System.out.println(request.getSession().getAttribute("rod"));
		return "ROd";
	}

	public TestInfo hello(String name)
	{
		System.out.println("Hello " + name);
		TestInfo info = new TestInfo();
		info.setName("ROd");
		info.setLastNames(new String[]{"aa", "bb"});
		return info;
	}

	public String[] hello(int times)
	{
		System.out.println("Hello " + times + " times");
		return new String[]{"rod", "zac"};
	}

	public void hello(boolean isHello)
	{
		System.out.println(isHello ? "Hello world!" : "Bye world");
	}

	public void hello(HelloInfo info)
	{
		System.out.println("Hello " + info.getName() + " " + info.getLastName());
	}

	public void hello(TestInfo info)
	{
		System.out.print("Hello " + info.getName());
		for(String tmp : info.getLastNames())
			System.out.print(" " + tmp);
		System.out.println("");
	}

	public void hello(String[] args)
	{
		System.out.print("Hello");
		for(String tmp : args)
			System.out.print(" " + tmp);
		System.out.println("");
	}

	public void hello(int[] args)
	{
		System.out.print("Hello");
		for(int tmp : args)
			System.out.print(" " + tmp);
		System.out.println("");
	}

}
